//
// File:	Inputs.cpp
// Author:	Thomas TISSOT-DUPONT
// Login:	<thomas.tissotdupont@free.fr>
//
// Create:	30/01/2010 at 05:14:51
// Purpose:	
//
#include "Inputs.hpp"

//------------------------------------------------------------------
// Keyboard
//------------------------------------------------------------------
bool InputKeyboard::HasInput(RenderCanvas *pRenderCanvas, sf::Key::Code keyCode) const
{
	return pRenderCanvas->GetInput().IsKeyDown(keyCode);
}

const InputKeyboard::BindingMapType &InputKeyboard::GetBindingNames()
{
	static InputKeyboard::BindingMapType bindings;
	if (bindings.empty())
	{
		bindings["key_a"] = sf::Key::A;
		bindings["key_b"] = sf::Key::B;
		bindings["key_c"] = sf::Key::C;
		bindings["key_d"] = sf::Key::D;
		bindings["key_e"] = sf::Key::E;
		bindings["key_f"] = sf::Key::F;
		bindings["key_g"] = sf::Key::G;
		bindings["key_h"] = sf::Key::H;
		bindings["key_i"] = sf::Key::I;
		bindings["key_j"] = sf::Key::J;
		bindings["key_k"] = sf::Key::K;
		bindings["key_l"] = sf::Key::L;
		bindings["key_m"] = sf::Key::M;
		bindings["key_n"] = sf::Key::N;
		bindings["key_o"] = sf::Key::O;
		bindings["key_p"] = sf::Key::P;
		bindings["key_q"] = sf::Key::Q;
		bindings["key_r"] = sf::Key::R;
		bindings["key_s"] = sf::Key::S;
		bindings["key_t"] = sf::Key::T;
		bindings["key_u"] = sf::Key::U;
		bindings["key_v"] = sf::Key::V;
		bindings["key_w"] = sf::Key::W;
		bindings["key_x"] = sf::Key::X;
		bindings["key_y"] = sf::Key::Y;
		bindings["key_z"] = sf::Key::Z;
		bindings["key_num_0"] = sf::Key::Num0;
		bindings["key_num_1"] = sf::Key::Num1;
		bindings["key_num_2"] = sf::Key::Num2;
		bindings["key_num_3"] = sf::Key::Num3;
		bindings["key_num_4"] = sf::Key::Num4;
		bindings["key_num_5"] = sf::Key::Num5;
		bindings["key_num_6"] = sf::Key::Num6;
		bindings["key_num_7"] = sf::Key::Num7;
		bindings["key_num_8"] = sf::Key::Num8;
		bindings["key_num_9"] = sf::Key::Num9;
		bindings["key_space"] = sf::Key::Space;
		bindings["key_lalt"] = sf::Key::LAlt;
		bindings["key_lbracket"] = sf::Key::LBracket;
		bindings["key_lcontrol"] = sf::Key::LControl;
		bindings["key_lshift"] = sf::Key::LShift;
		bindings["key_lsystem"] = sf::Key::LSystem;
		bindings["key_ralt"] = sf::Key::RAlt;
		bindings["key_rbracket"] = sf::Key::RBracket;
		bindings["key_rcontrol"] = sf::Key::RControl;
		bindings["key_return"] = sf::Key::Return;
		bindings["key_rshift"] = sf::Key::RShift;
		bindings["key_rsystem"] = sf::Key::RSystem;
		bindings["key_up"] = sf::Key::Up;
		bindings["key_down"] = sf::Key::Down;
		bindings["key_left"] = sf::Key::Left;
		bindings["key_right"] = sf::Key::Right;
		bindings["key_escape"] = sf::Key::Escape;
		bindings["key_tab"] = sf::Key::Tab;
		bindings["key_back"] = sf::Key::Back;
		bindings["key_backslash"] = sf::Key::BackSlash;
		bindings["key_comma"] = sf::Key::Comma;
		bindings["key_semicolon"] = sf::Key::SemiColon;
		bindings["key_dash"] = sf::Key::Dash;
		bindings["key_delete"] = sf::Key::Delete;
		bindings["key_divide"] = sf::Key::Divide;
		bindings["key_end"] = sf::Key::End;
		bindings["key_equal"] = sf::Key::Equal;
		bindings["key_f1"] = sf::Key::F1;
		bindings["key_f2"] = sf::Key::F2;
		bindings["key_f3"] = sf::Key::F3;
		bindings["key_f4"] = sf::Key::F4;
		bindings["key_f5"] = sf::Key::F5;
		bindings["key_f6"] = sf::Key::F6;
		bindings["key_f7"] = sf::Key::F7;
		bindings["key_f8"] = sf::Key::F8;
		bindings["key_f9"] = sf::Key::F9;
		bindings["key_f10"] = sf::Key::F10;
		bindings["key_f11"] = sf::Key::F11;
		bindings["key_f12"] = sf::Key::F12;
		bindings["key_home"] = sf::Key::Home;
		bindings["key_insert"] = sf::Key::Insert;
		bindings["key_menu"] = sf::Key::Menu;
		bindings["key_numpad0"] = sf::Key::Numpad0;
		bindings["key_numpad1"] = sf::Key::Numpad1;
		bindings["key_numpad2"] = sf::Key::Numpad2;
		bindings["key_numpad3"] = sf::Key::Numpad3;
		bindings["key_numpad4"] = sf::Key::Numpad4;
		bindings["key_numpad5"] = sf::Key::Numpad5;
		bindings["key_numpad6"] = sf::Key::Numpad6;
		bindings["key_numpad7"] = sf::Key::Numpad7;
		bindings["key_numpad8"] = sf::Key::Numpad8;
		bindings["key_numpad9"] = sf::Key::Numpad9;
		bindings["key_pgdn"] = sf::Key::PageDown;
		bindings["key_pgup"] = sf::Key::PageUp;
		bindings["key_pause"] = sf::Key::Pause;
		bindings["key_period"] = sf::Key::Period;
		bindings["key_quote"] = sf::Key::Quote;
		bindings["key_slash"] = sf::Key::Slash;
		bindings["key_substract"] = sf::Key::Subtract;
		bindings["key_tilde"] = sf::Key::Tilde;
	}
	return bindings;
}

//------------------------------------------------------------------
// Mouse
//------------------------------------------------------------------
bool InputMouse::HasInput(RenderCanvas *pRenderCanvas, sf::Mouse::Button mouseButton) const
{
	return pRenderCanvas->GetInput().IsMouseButtonDown(mouseButton);
}

const InputMouse::BindingMapType &InputMouse::GetBindingNames()
{
	static InputMouse::BindingMapType bindings;
	if (bindings.empty())
	{
		bindings["mouse_left"] = sf::Mouse::Left;
		bindings["mouse_right"] = sf::Mouse::Right;
		bindings["mouse_middle"] = sf::Mouse::Middle;
	}
	return bindings;
}
